/* 小写转大写 */
export const uppercase = (value) => {
    if (!value) { return ''}
    value = value.toString();
    return value.toUpperCase()
}
/* 点数转百分比 */
export const pointChange = (value) => {
  var percentVal =  Number(parseFloat(value * 100).toFixed(4).slice(0,-2));
  var s = percentVal.toString(); 
  var rs = s.indexOf('.'); 
  if (rs < 0) { 
  rs = s.length; 
    s += '.'; 
  } 
  while (s.length <= rs + 2) { 
    s += '0'; 
  }
  s = s + '%';
  return s;
}
/* 点数转百分比，去百分比 */
export const pointNoneChangeEls = (value) => {
  var percentVal =  Number(parseFloat(value).toFixed(4).slice(0,-2));
  var s = percentVal.toString(); 
  var rs = s.indexOf('.'); 
  if (rs < 0) { 
  rs = s.length; 
    s += '.'; 
  } 
  while (s.length <= rs + 2) { 
    s += '0'; 
  }
  return s;
}
/* 百分比转点数，去百分比 */
export const persetChangeEls = (value) => {
  var percentVal =  Number(parseFloat(value/100).toFixed(4).slice(0,-2));
  var s = percentVal.toString(); 
  var rs = s.indexOf('.'); 
  if (rs < 0) { 
  rs = s.length; 
    s += '.'; 
  } 
  while (s.length <= rs + 2) { 
    s += '0'; 
  }
  return s;
}
/* 时间戳（10位）转 2018-05-01 08:03:05 格式  */
export const formatTime = (value) => {
	var d = new Date(value*1000);
  var year = d.getFullYear();
  var month = d.getMonth() + 1;
  var day = d.getDate();
  var hour = d.getHours();
  var minutes = d.getMinutes();
  var seconds = d.getSeconds();
	month < 10 ? (month = "0" + month) : month;
	day < 10 ? (day = "0" + day) : day;
	hour < 10 ? (hour = "0" + hour) : hour;
	minutes < 10 ? (minutes = "0" + minutes) : minutes;
	seconds < 10 ? (seconds = "0" + seconds) : seconds;
    return year+ '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds;
}
/* 时间戳（10位）转 2018-05-01 格式  */
export const formatData = (value) => {
  var d = new Date(value*1000);
  var year = d.getFullYear();
  var month = d.getMonth() + 1;
  var day = d.getDate();
  var hour = d.getHours();
  var minutes = d.getMinutes();
  var seconds = d.getSeconds();
  month < 10 ? (month = "0" + month) : month;
  day < 10 ? (day = "0" + day) : day;
  hour < 10 ? (hour = "0" + hour) : hour;
  minutes < 10 ? (minutes = "0" + minutes) : minutes;
  seconds < 10 ? (seconds = "0" + seconds) : seconds;
    return year+ '-' + month + '-' + day;
}
//大于0的整数
export const integer = (value) => {
  if(value.length==1){
    return value.replace(/[^1-9]/g,'')
  }else{
    return value.replace(/\D/g,'')
  }
};
//保留两位小数
export const floor2 = (value) => {
  return Math.floor(value * 100) / 100;
};
//保留三位小数
export const floor3 = (value) => {
  return Math.floor(value * 1000) / 1000;
};

